#pragma once

#include <istream>
#include <ostream>




namespace boostext
{
	/**
	 * The space_tag is a dummy structure that can be used to consume ONE space or tab character
	 * from an input-stream. It will consume that character only if it's there and does NOT
	 * set a failbit if there is no space.
	 *
	 * Usage:
	 * boost_ext::space_tag s;
	 * stream >> s;
	 */
	struct space_tag
	{};
	///////////////////////////////////////////////////////////////////////////////////////////////

	/**
	 * The spaces_tag is a dummy structure that can be used to consume multiple spaces or tab characters
	 * from an input-stream. It will consume all characters until it encounters a nonspace or nontab character.
	 */
	struct spaces_tag
	{};
	///////////////////////////////////////////////////////////////////////////////////////////////



	template <class Ch, class Tr>
	std::basic_istream<Ch, Tr>& operator>>(std::basic_istream<Ch, Tr>& stream, space_tag&)
	{
		Ch c;
		if((c = stream.peek()) == ' ' || c == '\t')
			stream >> c;

		return stream;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////




	template <class Ch, class Tr>
	std::basic_istream<Ch, Tr>& operator>>(std::basic_istream<Ch, Tr>& stream, spaces_tag&)
	{
		Ch c;
		while((c = stream.peek()) == ' ' || c == '\t')
			stream >> c;

		return stream;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////

}
///////////////////////////////////////////////////////////////////////////////////////////////////
